//
//  SelectPhotoCell.m
//  PigMarket
//
//  Created by Felix on 2019/4/1.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "SelectPhotoCell.h"

@interface SelectPhotoCell ()

@end

@implementation SelectPhotoCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.deleteBtn];
}
- (void)initLayout {
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(5);
        make.right.bottom.mas_equalTo(-5);
    }];
    [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.mas_equalTo(0);
    }];
}

#pragma mark - getter and setter

- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        _imageView.contentMode = UIViewContentModeScaleToFill;
        _imageView.layer.cornerRadius = 4;
        _imageView.layer.masksToBounds = YES;
    }
    return _imageView;
}
- (UIButton *)deleteBtn {
    if (!_deleteBtn) {
        _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleteBtn.adjustsImageWhenHighlighted = NO;
        [_deleteBtn setBackgroundImage:[UIImage imageNamed:@"user_modifyphoto_delete"] forState:UIControlStateNormal];
    }
    return _deleteBtn;
}

@end
